#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

int main() {
    int n = 0, m = 0;
    scanf("%d %d", &n, &m);
    int arr[10][10] = { 0 };

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }

    int k = 0;
    scanf("%d", &k);
    char t = 0;
    int a = 0, b = 0;

    while (k)
    {
        getchar();
        scanf("%c %d %d", &t, &a, &b);
        if (t == 'r')
        {
            int temp = 0;
            for (int l = 0; l < m; l++)
            {
                temp = arr[a-1][l];
                arr[a-1][l] = arr[b-1][l];
                arr[b-1][l] = temp;
            }
        }
        if (t == 'c')
        {
            int temp = 0;
            for (int l = 0; l < n; l++)
            {
                temp = arr[l][a-1];
                arr[l][a-1] = arr[l][b-1];
                arr[l][b-1] = temp;
            }
        }
        k--;
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}